package top.laoshuzi.rpi3

class PwmMusic {

    private var pwmFrequency: Int = 100000

    private val frequency: Array<Int> = arrayOf(
            262, 294, 330, 349, 392, 440, 494,
            523, 587, 659, 698, 784, 880, 988,
            1047, 1175, 1319, 1397, 1568, 1760, 1976
    )

    fun setPwmFrequency(pwmFrequency: Int) {
        this.pwmFrequency = pwmFrequency
    }

    fun getDate(tone: Int, scale: Int): Int {
        return pwmFrequency / frequency[(tone - 1) + 7 * scale]
    }

}